#include "Connector.h"
#include "../Model/GameModel.h"
#include "../Logger/Logger.h"
Connector::Connector(): model_(0)
{
}

Connector::Connector(GameModel &model): model_(&model)
{
}

int Connector::openCard(int playerNum) const
{
  if(model_->getArrowsInsideFlag() != 0)
  {
    return 0;
  }
  if (playerNum == model_->getCurrentTurn())
  {
    return model_->openCard(playerNum);
  }
}

int Connector::getTotem(int playerNum) const
{
  return model_->getTotem(playerNum);
}

int Connector::startGame(bool toShuffle) const
{
  return model_->startGame(toShuffle);
}

int Connector::connect(const std::string &name, const time_t &connectTime, int &error)
{
  return model_->addPlayer(name, connectTime, error);
}

void Connector::setCards(const std::vector<Card>& cards)
{
  model_->setCards(cards);
}

int Connector::setModel(GameModel &model)
{
  if(model_ != 0)
  {
    return 1;
  }
  model_ = &model;
  return 0;
}

GameModel* Connector::getModel() const
{
  return model_;
}
